import { Subject } from 'rxjs';

export class TitleService {
    //private title: string = "Default Title";
    private titleChange$ = new Subject<string>();

    constructor() {
        this.titleChange$.subscribe((newTitle) => {
            //this.title = newTitle;
            console.log("======================");
            
            document.title = newTitle;
        });

        this.titleChange$.subscribe((newTitle) => {
            //this.title = newTitle;
            console.log("======================》2" + newTitle);
            
            document.title = newTitle;
        });
    }

    getTitleChange$() {
        return this.titleChange$.asObservable();
    }

    setTitle(newTitle: string) {
        this.titleChange$.next(newTitle); 
    }
}